package com.example.nbb.Controller;

import com.example.nbb.Service.LooseChangeService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@CrossOrigin//跨域
@RestController//遵循RestFul
@RequestMapping("/nbb/LooseChange/")
public class LooseChangeController {

    @Resource
    LooseChangeService looseChangeService;


    @GetMapping("getLooseChange")
    public String getAll(@RequestParam("userId") int userId) {
        return looseChangeService.selectByUserId(userId);
    }

    @PostMapping("decreaseLooseChange")
    public String addCollection(@RequestParam("userId") int userId, @RequestParam("looseChange") double looseChange) {
        return looseChangeService.decreaseLooseChange(userId, looseChange);
    }

    @PostMapping("augmentLooseChange")
    public String augmentLooseChange(@RequestParam("userId") int userId, @RequestParam("looseChange") double looseChange) {
        return looseChangeService.augmentLooseChange(userId, looseChange);
    }
}
